cmake_minimum_required(VERSION 3.14)
project(cafe LANGUAGES C CXX)

set(CMAKE_C_STANDARD 99)
set(CMAKE_CXX_STANDARD 17)

# 查找 Qt6 Widgets
set(CMAKE_PREFIX_PATH "C:/Qt/6.9.0/mingw_64/lib/cmake")
find_package(Qt6 COMPONENTS Widgets REQUIRED)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTORCC ON)


# Define the absolute path to the source data directory
set(SOURCE_DATA_DIR_PATH ${CMAKE_SOURCE_DIR}/data)
# Escape backslashes for C string literal compatibility on Windows
string(REPLACE "\\" "\\\\" SOURCE_DATA_DIR_PATH_ESCAPED ${SOURCE_DATA_DIR_PATH})

# 后端C静态库
add_library(backend STATIC
    backend/user.c
    backend/drink.c
    backend/order.c
)
target_include_directories(backend PUBLIC backend)
# Define the data path macro for the backend library
target_compile_definitions(backend PRIVATE SOURCE_DATA_PATH="${SOURCE_DATA_DIR_PATH_ESCAPED}")


# Qt GUI 示例（包含动画商品卡片+数据展示）
add_executable(qt_demo
    gui/qt_demo.cpp
    gui/DarkFoodCard.cpp
    gui/loginwindow.cpp
    gui/mainwindow.cpp
    gui/usermanagementpanel.cpp
    gui/productmanagementpanel.cpp
    gui/ordermanagementpanel.cpp
    gui/myorderspanel.cpp
    gui/orderingpanel.cpp      # Add the ordering panel
    gui/shoppingcartdialog.cpp # Add the shopping cart dialog
    resources.qrc              # Add the resource file
)
target_link_libraries(qt_demo PRIVATE backend Qt6::Widgets)
target_include_directories(qt_demo PRIVATE gui backend)
# Define the data path macro for the qt_demo executable (needed for direct access in GUI)
target_compile_definitions(qt_demo PRIVATE SOURCE_DATA_PATH="${SOURCE_DATA_DIR_PATH_ESCAPED}")

# --- Removed Data Directory Copying Logic ---
# The copy_data target and add_dependencies are no longer needed
# as we will access the source data directory directly.
